<script>
import Vue from 'vue';
export default {
	onLaunch: function () {
		uni.getSystemInfo({
			success: (e) => {
				console.log(e, '系统参数');
				let StatusBar = e.statusBarHeight || 0;
				let topheight = 0;
				let navheight = 40;
				let bottomSafeHeight = 0;
				let subject = {
					navstyle: {
						color: '#333',
						backgroundColor: '#fff'
					}
				};
				// #ifdef MP-WEIXIN || MP-QQ
				let capsule = wx.getMenuButtonBoundingClientRect();
				StatusBar = e.statusBarHeight;
				console.log('获取菜单按钮（右上角胶囊按钮）的布局位置信息', capsule);
				// StatusBarHeight = e.statusBarHeight;
				if (capsule) {
					Vue.prototype.Custom = capsule;
					// Vue.prototype.capsuleSafe = uni.upx2px(750) - capsule.left + uni.upx2px(750) - capsule.right;
					navheight = capsule.bottom - capsule.top + (capsule.top - e.statusBarHeight) * 2;
					topheight = capsule.bottom + capsule.top - e.statusBarHeight;
				} else {
					topheight = e.statusBarHeight + 50;
				}
				if (e.safeArea) {
					bottomSafeHeight = e.screenHeight - e.safeArea.bottom;
				}

				// #endif

				// #ifdef MP-ALIPAY
				StatusBar = e.statusBarHeight;
				topheight = e.statusBarHeight + e.titleBarHeight;
				// #endif

				Vue.prototype.theme = 'light'; //主题色，默认白色
				if (e.theme) {
					Vue.prototype.theme = e.theme;
					if (e.theme != 'light') {
						subject = {
							navstyle: {
								color: '#fff',
								backgroundColor: '#333'
							}
						};
					}
				}
				// 小程序中 Vue.prototype.Custom 是 （右上角胶囊按钮）的布局位置信息对象
				Vue.prototype.StatusBar = StatusBar; //状态栏的高度
				Vue.prototype.topheight = topheight; // 状态栏+导航条的高度
				Vue.prototype.navheight = navheight; //导航条的高度

				Vue.prototype.subject = subject;
				Vue.prototype.bottomSafeHeight = bottomSafeHeight; //底部安全区域高度;
				Vue.prototype.screenWidth = e.screenWidth;//系统的高度
			}
		});

		Vue.prototype.ColorList = [
			{
				title: '嫣红',
				name: 'red',
				color: '#e54d42'
			},
			{
				title: '桔橙',
				name: 'orange',
				color: '#f37b1d'
			},
			{
				title: '明黄',
				name: 'yellow',
				color: '#fbbd08'
			},
			{
				title: '橄榄',
				name: 'olive',
				color: '#8dc63f'
			},
			{
				title: '森绿',
				name: 'green',
				color: '#39b54a'
			},
			{
				title: '天青',
				name: 'cyan',
				color: '#1cbbb4'
			},
			{
				title: '海蓝',
				name: 'blue',
				color: '#0081ff'
			},
			{
				title: '姹紫',
				name: 'purple',
				color: '#6739b6'
			},
			{
				title: '木槿',
				name: 'mauve',
				color: '#9c26b0'
			},
			{
				title: '桃粉',
				name: 'pink',
				color: '#e03997'
			},
			{
				title: '棕褐',
				name: 'brown',
				color: '#a5673f'
			},
			{
				title: '玄灰',
				name: 'grey',
				color: '#8799a3'
			},
			{
				title: '草灰',
				name: 'gray',
				color: '#aaaaaa'
			},
			{
				title: '墨黑',
				name: 'black',
				color: '#333333'
			},
			{
				title: '雅白',
				name: 'white',
				color: '#ffffff'
			}
		];

		// #ifdef APP-PLUS
		if (plus && plus.os.name == 'Android') {
			plus.android.requestPermissions(
				[
					'android.permission.ANSWER_PHONE_CALLS', //手动 挂断和接听 需要这个权限
					'android.permission.MODIFY_AUDIO_SETTINGS', //手动 挂断和接听 需要这个权限
					'android.permission.CALL_PHONE', //手动 挂断和接听 需要这个权限
					'android.permission.READ_PHONE_STATE', //>监听电话状态 需要这个权限
					'android.permission.READ_CALL_LOG', //获取号码需要这个权限
					'android.permission.READ_AUDIO' // 录音权限
				],
				function (resultObj) {
					var result = 0;
					for (var i = 0; i < resultObj.granted.length; i++) {
						var grantedPermission = resultObj.granted[i];
						console.log('已获取的权限：' + grantedPermission);
						result = 1;
					}
					for (var i = 0; i < resultObj.deniedPresent.length; i++) {
						var deniedPresentPermission = resultObj.deniedPresent[i];
						console.log('拒绝本次申请的权限：' + deniedPresentPermission);
						result = 0;
					}
					for (var i = 0; i < resultObj.deniedAlways.length; i++) {
						var deniedAlwaysPermission = resultObj.deniedAlways[i];
						console.log('永久拒绝申请的权限：' + deniedAlwaysPermission);
						result = -1;
					}
				},
				function (error) {
					console.log('申请权限错误：' + error.code + ' = ' + error.message);
				}
			);
		}
		// #endif
	},
	onShow: function () {},
	onHide: function () {}
};
</script>

<style lang="scss">
/* 重置默认样式 */
@import 'static/css/reset.css';
/*每个页面公共css */
@import '@/uni_modules/uni-scss/index.scss';

@import '@/static/customicons.css';
/* 图标库 */
@import 'static/css/iconfont.css';

// 设置整个项目的背景色
page {
	background-color: #f5f5f5;
	height: 100%;
}

body {
	height: 100%;
}
</style>
